import axios from '@/utils/axios'

export const login = (username: string, password: string): Promise<ApiResult<string>> => {
  return axios.post(`base/login`, { username: username, password: password })
}

export const logout = (id: string): Promise<ApiResult<void>> => {
  return axios.post(`base/logout/${id}`)
}

export const getUserInfo = (): Promise<ApiResult<UserInfo>> => {
  return axios.get(`base/userinfo`)
}

export const getRoleInfo = (): Promise<ApiResult<RoleInfo[]>> => {
  return axios.get(`base/roleinfo`)
}

export const getMenuInfo = (roleId: string): Promise<ApiResult<MenuInfo[]>> => {
  return axios.get(`base/menuinfo/${roleId}`)
}

export const getCodeInfo = (): Promise<ApiResult<CodeInfo[]>> => {
  return axios.get(`base/codeinfo`)
}
